package com.zzh.lib.views.adapter.holder;

import android.util.SparseArray;
import android.view.View;

/**
 * Created by ZZH on 2022/6/22.
 *
 * @Date: 2022/6/22
 * @Email: zzh_hz@126.com
 * @QQ: 1299234582
 * @Author: zzh
 * @Description:
 */
public class HBaseViewHolder {

    private final SparseArray<View> views;
    private final View itemView;

    public HBaseViewHolder(View itemView) {
        this.itemView = itemView;
        this.views = new SparseArray<>();
    }

    public View getItemView() {
        return itemView;
    }

    public <T extends View> T getView(int viewId) {
        View view = views.get(viewId);
        if (view == null) {
            view = itemView.findViewById(viewId);
            views.put(viewId, view);
        }
        return (T) view;
    }
}
